#ifndef CAMERA_H
#define CAMERA_H

#include "d3dUtil.h"
#include "TypeUtil.h"

#include "Logger.h"

//message system stuff
#include "GlobalMessage.h"
#include "MessageQueryer.h"
#include "MouseSubject.h"
#include "MouseListener.h"
#include "KeyboardListener.h"
#include "KeyboardSubject.h"

#include "SceneNode.h"

class Camera : public SceneNode , public MouseListener , public KeyboardListener
{
public:
	Camera(void);
	~Camera(void);

	void Init();

	//return the camera's view matrix
	D3DXMATRIX		GetViewMatrix();

	//update the camera's view matrix
	void			UpdateViewMatrix();

	D3DXVECTOR3		GetPosition();
	D3DXVECTOR3		GetLookAt();
	D3DXVECTOR3		GetUp();

	virtual void	MouseUpdate(MouseMsg msg,const Point& oldPoint,const Point& currPoint);
	virtual void	KeyboardUpdate(KeyboadMsg msg);



	void			SetPosition(const D3DXVECTOR3& vec3);
	void			SetLookAt(const D3DXVECTOR3& vec3);
	void			SetUp(const D3DXVECTOR3& vec3);
	void			SetPitchFactor(double factor);
	void			SetYawFactor(double factor);
	void			SetRollFactor(double factor);
	void			SetSpeed(double speed);

private:
	void			mouseMove(const Point& oldPoint,const Point& currPoint);
	void			walk(Direction direction);
	void			yaw(float angle);
	void			pitch(float angle);
	void			roll(float angle);
	void			rotateY(float angle);

private:
	D3DXVECTOR3		m_vec3Position;
	D3DXVECTOR3		m_vec3LookAt;
	D3DXVECTOR3		m_vec3Up;

	D3DXMATRIX		m_matView;

	double			m_dfSpeed;
	double			m_dfPitchFactor;
	double			m_dfYawFactor;
	double			m_dfRollFactor;
};


#endif

